package com.usian.controller;

import com.usian.pojo.Zhuce;
import com.usian.service.ZhuceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/clzc")
public class CLZCController {

    @Autowired
    private ZhuceService zhuceService;

    @RequestMapping("/toClzc")
    public String toClzc(){
        return "Cldl";
    }
    @RequestMapping("/Cldl")
    public String clzc(Zhuce zhuce, HttpSession httpSession){
        List<Zhuce> zhuceList = zhuceService.findZhuce(zhuce);
        if (zhuceList.size()>0){
            httpSession.setAttribute("zhuce",zhuceList.get(0));
            if (zhuce.getUzid()==0){
                return "redirect:/cl/findGL";
            }else {
                return "redirect:/cl/findAll";
            }
        }
        return "Cldl";
    }
}
